﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UPNP.IO.ValueConverters
{
    internal sealed class DeviceBase64Converter : IDeviceValueConverter
    {
        public Type ManagedType
        {
            get { return typeof(byte[]); }
        }

        public object FromDevice(string value)
        {
            return Convert.FromBase64String(value);
        }

        public string ToDevice(object value)
        {
            if (!(value is byte[]))
                throw new ArgumentException("only byte[] is accepted", "value");

            return Convert.ToBase64String((byte[])value);
        }
    }
}
